'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	let res111 = await uniCloud.httpclient.request(
		event.dyurl, {
			method: "GET",
			dataType: 'text'
		})
	let mid=res111.headers.location.split("/")[5]
	let body= await uniCloud.httpclient.request("https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids="+mid,{dataType: 'text'});
	
	body=JSON.parse(body.data)
	console.log('body---- body', body)
	res111={desc:body.item_list[0].desc,video:body.item_list[0].video.play_addr.url_list[0].replace("playwm","play"),
	image:body.item_list[0].video.origin_cover.url_list[0],
	music:body.item_list[0].music.play_url.url_list[0]
	}
	//把视频地址转换成无水印的
	let temp=await uniCloud.httpclient.request(
	res111.video,{method:"GET",
	dataType: 'text'})
	res111.video=temp.headers.location
	console.log('res111---- res111', res111)
	
	//返回数据给客户端
	return res111
};
